/* This code generates Romer-Romer monetary policy shocks from Greenbook forecastsas in Romer and Romer (2004). The shock series is updated up through 2007. Written by Johannes Wieland and provided without any warranty. This version: December 2017*/#delimit;cap log close;clear;set more 1;/*************************************************************************************************************1. User Controls*************************************************************************************************************/cd "~/Dropbox/Monetary Policy with Heterogenous Producers/Empirical Calibrations/data/Monetary_shocks";/* This control determines whether the October 6, 1979 meeting is included. This meeting is excluded in the baseline because the forecast is made on October 12and is based on responses to the policy change. See the discussion in the Greenbook forecast. */local includeOct1979 = 0; /* set to 1 to include *//*************************************************************************************************************2. Dataset construction*************************************************************************************************************//*******************************************************************************2a. Import original and extended Romer-Romer data*******************************************************************************/import excel using "RRimport.xlsx", firstrow case(lower);/* meeting month and day for merge with forecast data */gen meeting_month = ym(year,month);qui gen day = floor((mtgdate-month*10000)/100);qui gen meeting_date = mdy(month,day,year);format meeting_date %td;/* at the beginning of the sample some months have two meetings. I reset the meetingvariable here so I can use more robust 1:1 matches later. */duplicates tag meeting_month, gen(meetdup);replace meeting_month = meeting_month + 0.5*(day>20)*(meetdup==1);qui drop day meetdup;tempfile rrmonshock;save `rrmonshock', replace;	/*******************************************************************************2b. Release dates for forecasts not in Fred and meeting dates for meetings not in Romer data*******************************************************************************//* these are forecast release dates matched to meeting days that are notcontained in the FRED data. */import excel using "ForecastRelease.xlsx", firstrow case(lower) clear;/* meeting date */qui gen meeting_date = mdy(month,day,year);format meeting_date %td;/* release date */qui gen release_date = mdy(fc_month,fc_day,fc_year);format release_date %td;qui gen dist = meeting_date-release_date;tab dist;/* saving file for merge */qui keep meeting_date release_date mtgdate;tempfile additionalreleases;save `additionalreleases', replace;	/*******************************************************************************2c. Compiling excel data from Philadelphia Fedhttps://www.philadelphiafed.org/research-and-data/real-time-center/greenbook-data/pdf-data-set*******************************************************************************//*The Philadelphia Fed has published excel files with Greenbook forecasts. These areimported here and cross-checked with the FRED data and the manually entered data inthe Romer-Romer excel file.*//* importing excel files and converting to Stata long form */local philvars `"unemp"' `"grgdp"'  `"gpgdp"'  `"gngdp"'; local philsheets `"_1967_1984"' `"_1985_last"';foreach variable in `"`philvars'"' {;		local capvar = upper("`variable'");		foreach sheet in `"`philsheets'"' {;				import excel using "RRshock_xls/`capvar'`sheet'.xlsx", firstrow case(lower) clear;				/* quarter for which forecast is made */		qui gen fc_year = floor(date);		qui gen quarter = (date-fc_year)*10;		qui gen fc_quarter = yq(fc_year,quarter);		format fc_quarter %tq;		qui drop quarter date;				/* reshape data */		qui reshape long `variable', i(fc_quarter) j(release_date) string;		qui replace release_date = substr(release_date,2,.);		qui destring release_date, replace;				/* saving */		tempfile `capvar'`sheet';		save ``capvar'`sheet'';	};};/* combining datasets */foreach variable in `"`philvars'"' {;		local capvar = upper("`variable'");		foreach sheet in `"`philsheets'"' {;			if `"`variable'"'==`"unemp"' && `"`sheet'"'==`"_1967_1984"' {;			use ``capvar'`sheet'', clear;		};		else if `"`variable'"'==`"unemp"' && `"`sheet'"'==`"_1985_last"' {;			append using ``capvar'`sheet'';		};		else {;			merge 1:1 fc_quarter release_date using ``capvar'`sheet'', nogenerate update;		};				};	};	/* incorrect relase date in Philadelphia data (double checked in original Greenbook) */replace release_date=19910626 if release_date==19910628;replace release_date=19940629 if release_date==19940630;/* cannot verify the existence of this forecast anywhere else. there is aGreenbook forecast from 1/30/1968 for the 2/6/1968 meeting. but neither theFOMC website nor the Philadelphia Fed website have a physical copy.*/drop if release_date==19680206;/* assigning variable definitions based on Greenbooks */gen philgnp = grgdp if release_date<=19911030;gen philgdp = grgdp if release_date>19911030;gen philnomgnp = gngdp if release_date<=19911030;gen philnomgdp = gngdp if release_date>19911030;gen philgnpdefl = gpgdp if release_date<=19911030;gen philgdpdefl = gpgdp if release_date>19911030 & release_date<=19960501;gen philgdpchain = gpgdp if release_date>19960501;qui rename unemp 	philunemp;qui drop g?gdp;/* For the 1/29/1969 forecast the Greenbooks mention a supplement with additionalforecasts to be forthcoming, but I cannot find a record of it. I augment the data here with data from the Romer Greenbook file. If you find the record pleaselet me know!*/replace philgnp=1.4 if release_date==19690129 & fc_quarter==yq(1969,3);replace philgnpdefl=4.2 if release_date==19690129 & fc_quarter==yq(1969,3);/* Manual correction of incorrect entries in Philadelphia database. I checked in the original Greenbooks that the Philadelphia data are incorrect. */replace philgnp=0.1 if release_date==19691210 & fc_quarter==yq(1970,2);replace philgnpdefl=3.9 if release_date==19720913 & fc_quarter==yq(1973,1);replace philgnpdefl=3.4 if release_date==19720913 & fc_quarter==yq(1973,2);replace philgnpdefl=3.7 if release_date==19721011 & fc_quarter==yq(1973,1);replace philgnpdefl=3.5 if release_date==19721011 & fc_quarter==yq(1973,2);replace philgnpdefl=4.1 if release_date==19721115 & fc_quarter==yq(1973,1);replace philgnpdefl=3.5 if release_date==19721115 & fc_quarter==yq(1973,2);replace philgnpdefl=3.7 if release_date==19760512 & fc_quarter==yq(1976,1);replace philgnp=2.2 if release_date==19870701 & fc_quarter==yq(1987,2);replace philnomgnp=8.6 if release_date==19820623 & fc_quarter==yq(1983,4);replace philnomgnp=5.4 if release_date==19871209 & fc_quarter==yq(1987,4);replace philnomgnp=5.1 if release_date==19871209 & fc_quarter==yq(1988,1);replace philnomgnp=5.0 if release_date==19871209 & fc_quarter==yq(1988,2);replace philnomgnp=6.3 if release_date==19871209 & fc_quarter==yq(1988,3);replace philnomgnp=7.0 if release_date==19871209 & fc_quarter==yq(1988,4);replace philnomgnp=7.6 if release_date==19910626 & fc_quarter==yq(1991,4);replace philgdp=4.6 if release_date==19950322 & fc_quarter==yq(1994,4);/* There is a revised forecast available for 4/6/1970 that is not in the Phildadelphia database. */replace release_date=19700406 if release_date==19700401 ;replace philgnp=3.1 if release_date==19700406 & fc_quarter==yq(1970,3);replace philgnp=3.3 if release_date==19700406 & fc_quarter==yq(1970,4);replace philnomgdp=6.7 if release_date==19700406 & fc_quarter==yq(1970,2);	replace philnomgdp=5.9 if release_date==19700406 & fc_quarter==yq(1970,3);replace philnomgdp=6.9 if release_date==19700406 & fc_quarter==yq(1970,4);replace philgnpdefl=5.9 if release_date==19700406 & fc_quarter==yq(1970,2);replace philgnpdefl=2.9 if release_date==19700406 & fc_quarter==yq(1970,3);replace philgnpdefl=3.6 if release_date==19700406 & fc_quarter==yq(1970,4);replace philunemp=4.6 if release_date==19700406 & fc_quarter==yq(1970,3);replace philunemp=4.8 if release_date==19700406 & fc_quarter==yq(1970,4);/* There is a revised forecast available for 2/9/1971 that is not in the Phildadelphia database, but none of the variables I use have changed. */replace release_date=19710209 if release_date==19710203 ;/* The Philadelphia data quotes a release on 4/15/1977, but the Greenbooks date from 4/13/1977. I could not find a written record of a forecast for 4/15/1977, so I use the original 4/13 values. If you find documentation for this forecast please let me know! */replace release_date=19770413 if release_date==19770415 ;replace philgnp=7.2 if release_date==19770413 & fc_quarter==yq(1977,2);replace philgnp=6.4 if release_date==19770413 & fc_quarter==yq(1977,3);	/* check this */replace philgnp=5.9 if release_date==19770413 & fc_quarter==yq(1977,4);replace philgnp=5.7 if release_date==19770413 & fc_quarter==yq(1978,1);replace philgnp=5.6 if release_date==19770413 & fc_quarter==yq(1978,2);replace philnomgdp=13.7 if release_date==19770413 & fc_quarter==yq(1977,2);replace philnomgdp=12.4 if release_date==19770413 & fc_quarter==yq(1977,3);replace philnomgdp=12.8 if release_date==19770413 & fc_quarter==yq(1977,4);replace philnomgdp=11.7 if release_date==19770413 & fc_quarter==yq(1978,1);replace philnomgdp=11.3 if release_date==19770413 & fc_quarter==yq(1978,2);replace philgnpdefl=5.7 if release_date==19770413 & fc_quarter==yq(1977,3);replace philgnpdefl=6.6 if release_date==19770413 & fc_quarter==yq(1977,4);replace philgnpdefl=5.7 if release_date==19770413 & fc_quarter==yq(1978,1);replace philgnpdefl=5.4 if release_date==19770413 & fc_quarter==yq(1978,2);replace philunemp=7.1 if release_date==19770413 & fc_quarter==yq(1977,2);replace philunemp=7.0 if release_date==19770413 & fc_quarter==yq(1977,3);replace philunemp=6.9 if release_date==19770413 & fc_quarter==yq(1977,4);replace philunemp=6.7 if release_date==19770413 & fc_quarter==yq(1978,1);replace philunemp=6.6 if release_date==19770413 & fc_quarter==yq(1978,2);/* only match up to 2007 */qui drop if release_date>20080000;	tempfile philforecasts;save `philforecasts', replace;	/*******************************************************************************2d. Compiling data from FREDhttps://alfred.stlouisfed.org/category?cid=32213*******************************************************************************//* The following two text files contain the Greenbook forecasts in the Fred database.The code creates the forecast horizon variable fc_quarter */import delimited "RRshock_txt/RRshock_Quarterly_1.txt", clear;qui gen fc_year = substr(observation_date,1,4);qui gen fc_month = substr(observation_date,6,2);qui destring fc*, replace;qui gen fc_quarter = yq(fc_year,(fc_month+2)/3);qui format fc_quarter %tq;qui drop observation_date fc_year fc_month;qui order fc_quarter, first;tempfile rrshock_fred1;save `rrshock_fred1';import delimited "RRshock_txt/RRshock_Quarterly_2.txt", clear;qui gen fc_year = substr(observation_date,1,4);qui gen fc_month = substr(observation_date,6,2);qui destring fc*, replace;qui gen fc_quarter = yq(fc_year,(fc_month+2)/3);qui format fc_quarter %tq;qui drop observation_date fc_year fc_month;qui order fc_quarter, first;/* merging the two datasets */merge m:m fc_quarter using `rrshock_fred1', nogenerate;/* variable list in Greenbook forecasts */local fcvars gdpc1gbfp gdpctpigbfp gdpdefgbfp gdpgbfp gnpcgbfp gnpdefgbfp gnpgbfp unrategbf;/* labels for variables */local gdpc1gbfp_label 	"Real GDP";local gdpctpigbfp_label "GDP chained deflator";local gdpdefgbfp_label 	"GDP deflator";local gdpgbfp_label 	"Nominal GDP";local gnpcgbfp_label 	"Real GNP";local gnpdefgbfp_label 	"GNP deflator";local gnpgbfp_label 	"Nominal GNP";local unrategbf_label 	"Unemployment";/* reshape to long format. release_date is the date when the forecast is made. fc_quarter describes for which quarter the forecast is made */qui reshape long `fcvars', i(fc_quarter) j(release_date) string;qui replace release_date = substr(release_date,2,.);qui destring release_date, replace;/* incorrect relase date in FRED data (double checked in original Greenbook) */replace release_date=19780712 if release_date==19780711;replace release_date=19920626 if release_date==19920624;replace release_date=19930129 if release_date==19930127;	/* a new forecast was made two days later */replace release_date=19940316 if release_date==19940317;/* rename variables */qui rename gdpc1gbfp	gdp;qui rename gdpctpigbfp 	gdpchain;qui rename gdpdefgbfp 	gdpdefl;qui rename gdpgbfp 		nomgdp;qui rename gnpcgbfp 	gnp;qui rename gnpdefgbfp 	gnpdefl;qui rename gnpgbfp 		nomgnp;qui rename unrategbf 	unemp;/* Manual correction of incorrect entries in FRED database. I checked in the original Greenbooks that the FRED data are incorrect. */replace gnpdefl=7.1 if release_date==19790314 & fc_quarter==yq(1979,3);replace nomgnp=10.9 if release_date==19800103 & fc_quarter==yq(1979,4);replace gnp=0.7 if release_date==19801112 & fc_quarter==yq(1981,2);replace unemp=6.6 if release_date==19870325 & fc_quarter==yq(1988,2);replace gdpdefl=2.7 if release_date==19920626 & fc_quarter==yq(1992,2);replace nomgdp=4.9 if release_date==19920626 & fc_quarter==yq(1992,2);replace gdp=3.8 if release_date==19930129 & fc_quarter==yq(1992,4);replace gdpdefl=1.8 if release_date==19930129 & fc_quarter==yq(1992,4);replace nomgdp=5.7 if release_date==19930129 & fc_quarter==yq(1992,4);replace nomgdp=5.0 if release_date==19930129 & fc_quarter==yq(1993,4);replace nomgdp=6.0 if release_date==19940629 & fc_quarter==yq(1994,2);replace nomgdp=5.2 if release_date==20050316 & fc_quarter==yq(2006,4);/* merging with Philadelphia Fed data */merge 1:1 fc_quarter release_date using `philforecasts', generate(philfredmatch);sort release_date fc_quarter;/*******************************************************************************2e. Cross-checking FRED and Philadelphia forecasts*******************************************************************************//* Phildalphia data substitutes the chained GDP deflator index for the GDP deflatorafter May 1996 release. I keep using the GDP deflator, constructed from real andnominal GDP, for consistency. */*qui replace philgdpdefl = gdpdefl if release_date<19971211 & release_date>=19960501;qui replace philgdpdefl = philnomgdp-philgdp if release_date>=19971211;*mdy(12,11,1997);foreach var of varlist unemp gdp gnp nomgdp nomgnp gdpdefl gdpchain {;	qui gen diff`var' = `var'-phil`var';	qui replace diff`var' = .  if abs(diff`var')<0.0001;};su diff*;/* updating FRED data using philadelphia numbers */replace gnp = philgnp if gnp==.;replace gdp = philgdp if gdp==.;replace nomgnp = philnomgnp if nomgnp==.;replace nomgdp = philnomgdp if nomgdp==.;replace gnpdefl = philgnpdefl if gnpdefl==.;replace gdpdefl = philgdpdefl if gdpdefl==.;replace gdpchain = philgdpchain if gdpchain==.;replace unemp = philunemp if unemp==.;qui drop diff* phil*;/*******************************************************************************2f. Assign meeting dates to forecast releases*******************************************************************************//* Reformat date forecast is made to daily, monthly, quarterly */qui gen year = floor(release_date/10000);qui gen month = floor((release_date-year*10000)/100);qui gen day = (release_date-year*10000-month*100);qui replace release_date = mdy(month,day,year);format release_date %td;qui gen release_month = mofd(release_date);qui format release_month %tm;qui gen release_quarter = qofd(release_date);qui format release_quarter %tq;qui drop year month day;/* Merge meeting days from R&R dataset:This code looks if the forecast is matched with a meeting. First I check the match within the same calendar month. If there is no such match or the meeting is at the beginning of the month and the forecast at the end of the month, then Isearch for a match with the following month. */preserve;qui drop if year(release_date)<1978; /* these are already matched in part 2b *//* first try: is there a meeting in the month of the forecast */qui gen meeting_month = release_month;qui replace meeting_month = meeting_month+1 if release_date==mdy(1,30,1980);	/* this manual coding is necessary to get the 1:1 match right since two forecasts are made in January 1980 */keep meeting_month release_date;duplicates drop;merge 1:1 meeting_month using `rrmonshock', generate(meeting_match) keepusing(meeting_month mtgdate meeting_date) ;keep meeting_month release_date mtgdate meeting_date;qui gen dist = meeting_date-release_date;				/* dist is the distance between meeting day and forecast day *//* the following meetings have forecasts made at the end of the month before the meeting */qui drop if release_date==.;qui replace meeting_month = meeting_month+1 if dist<=-29;	/*-29 is a sufficient cut-off in this sample. when more data is added you may want to adjust it. check the output on tab dist below.*/qui replace meeting_month = meeting_month+1 if dist==.;merge 1:1 meeting_month using `rrmonshock', generate(meeting_match) keepusing(meeting_month mtgdate meeting_date) update replace;qui replace dist = meeting_date-release_date;/* distribution of distance between meeting date and forecast date for matched meeting-forecast observations */tab dist;		/* omit matches where the meeting date occurs before the forecast */qui replace mtgdate = . if dist<0;/* optionally include 10/1979 match */if "`includeOct1979'"=="1" {;	replace mtgdate = 100679 if release_date== mdy(10,12,1979);};/* keep matched meeting and forecast dates and merge to original data */qui keep release_date mtgdate meeting_date;qui drop if release_date==.;tempfile meetingmatches;save `meetingmatches';restore;merge m:1 release_date using `additionalreleases', nogenerate keepusing(mtgdate meeting_date);merge m:1 release_date using `meetingmatches', nogenerate keepusing(mtgdate meeting_date) update;/*******************************************************************************2g. Match with updated Romer-Romer file*******************************************************************************//* constructing forecast horizon based on forecast date and forecast horizon as in original Romer-Romer dataset */qui gen fc_horizon = fc_quarter-release_quarter;qui sort release_date fc_quarter;/* Construct a single time series in the dataset: 1. Combine GNP and GDP series. 2. When GDP deflator is no longer published use the difference between nominaland real GDP growth. */foreach set in ""  {;	qui replace gdp`set' = gnp`set' if release_date<=mdy(10,30,1991);	qui replace nomgdp`set' = nomgnp`set' if release_date<=mdy(10,30,1991);	qui replace gdpdefl`set' = gnpdefl`set' if release_date<=mdy(10,30,1991);	qui replace gdpdefl`set' = nomgdp`set'-gdp`set' if release_date>=mdy(12,11,1997);};qui drop *gnp* gdpchain;/* Creating forecast revision variables */qui egen meeting_no = group(meeting_date);tsset  fc_quarter meeting_no;foreach var of varlist *gdp* unemp {;	qui gen `var'_fcd = `var'-L.`var';};/* Keep only the forecast horizons used in the Romer-Romer regression */qui keep if fc_horizon>=-1 & fc_horizon<=2;qui sort meeting_date fc_quarter;/* reshape to Romer-Romer dataset format */qui drop fc_quarter fc_year meeting_no release_quarter  release_month ;qui tostring fc_horizon, replace;qui replace fc_horizon = "m" if fc_horizon=="-1";reshape wide *gdp* unemp*, i(meeting_date release_date mtgdate) j(fc_horizon) string ;/* merge with existing Romer-Romer dataset */merge 1:1 mtgdate using `rrmonshock', nogenerate;sort meeting_date;qui drop meeting_month;/* update 10/1979 observation */if "`includeOct1979'"!="1" {;	replace meeting_date = . if release_date== mdy(10,12,1979);};/*******************************************************************************2h. Updating and cross-checking updated Romer-Romer file*******************************************************************************//* Corrections for Romer data: For both data points the decimal was illegible/ambiguous in the original pdf document.*/replace graym = 0.3 if release_date==mdy(7,15,1970);replace igrym = igrym+0.1 if release_date==mdy(7,15,1970);replace igrym = igrym-0.1 if release_date==mdy(8,12,1970);replace grad1 = 3.5 if release_date==mdy(8,12,1970);replace igrd1 = igrd1+0.2 if release_date==mdy(8,12,1970);replace igrd1 = igrd1-0.2 if release_date==mdy(9,9,1970);/* The following forecast revisions are missing in the Philadelphia databecause the baseline forecasts are not available. Romer-Romer set the revisions to zero */foreach var of varlist *fcd2 {;	replace `var' = 0 if release_date==mdy(7,9,1969);};	/* Checking Romer-Romer dataset against forecasts */local regressors;foreach horizon in m 0 1 2 {;		local regressors `"`regressors' gdp`horizon' gdpdefl`horizon' gdp_fcd`horizon' gdpdefl_fcd`horizon' "';		/* These variables are used to check consistency over the two datasets */	qui gen diffgdp`horizon' = gdp`horizon' - gray`horizon';	qui gen diffgdpdefl`horizon' = gdpdefl`horizon' - grad`horizon';	qui gen diffgdp_fcd`horizon' = gdp_fcd`horizon' - igry`horizon';	qui gen diffgdpdefl_fcd`horizon' = gdpdefl_fcd`horizon' - igrd`horizon';};qui gen diffunemp0 = unemp0-grau0;local regressors `"`regressors' unemp0"';foreach var of varlist diff* {;	qui replace `var'=. if abs(`var')<0.0001;};su diff* if year<=1996;	/* differences in FRED/Philadelphia forecasts from Romer-Romer sample */su diff* if year>1996;	/* differences in FRED/Philadelphia forecasts from post-Romer-Romer sample */qui drop diff*;/*************************************************************************************************************3. Generating Monetary Shocks a la Romer-Romer (2004)*************************************************************************************************************/*Romer-Romer sample regression (original Romer-Romer data has missing observations from August-October 1972, which has since been published in updated Greenbook files);regress dtarg oldtarg `regressors' if year<=1996 & meeting_date!=mdy(10,6,1979) & (meeting_date<mdy(8,15,1972) | meeting_date>mdy(10,17,1972));qui predict resid_romer, r;*Full sample regression;regress dtarg oldtarg `regressors';qui predict resid_full, r;/* These variables are the original Romer-Romer variables. One can run these regressions to check if results are consistent */*Romer sample regression;regress dtarg oldtarg gradm grad0 grad1 grad2 igrdm igrd0 igrd1 igrd2 graym gray0 gray1 gray2 igrym igry0 igry1 igry2 grau0 if year<=1996 & meeting_date!=mdy(10,6,1979) & (meeting_date<mdy(8,15,1972) | meeting_date>mdy(10,17,1972)), r;*Full sample regression;regress dtarg oldtarg gradm grad0 grad1 grad2 igrdm igrd0 igrd1 igrd2 graym gray0 gray1 gray2 igrym igry0 igry1 igry2 grau0, r;* Compare RR shocks with full sample shocks;label variable resid "Original R&R shocks";label variable resid_romer "R&R shock based on original R&R regression";label variable resid_full "Full-sample R&R shocks";correlate resid resid_romer resid_full;/* Collapse romer shocks to monthly dating */qui gen date = ym(year,month);qui drop if date==.;qui keep date resid resid_romer resid_full;qui collapse (sum) resid resid_romer resid_full, by(date);tempfile rrshocks;save `rrshocks';/*************************************************************************************************************4. Exporting data in monthly, quarterly and annual frequency*************************************************************************************************************/clear all;/* Generating date variable extending back to 1969 */qui set obs 1;qui gen date = ym(1969,1);qui local diff	=	ym(2007,12)-ym(1969,1);forvalues jj=1(1)`diff' {;	qui local new = `jj'+1;	qui set obs `new';	qui replace date = ym(1969,1)+`jj' if date==.;};format date %tm;/* Merging with monetary shocks calculated above */qui merge m:1 date using `rrshocks', keepusing(resid resid_romer resid_full) nogenerate;foreach var of varlist resid resid_romer resid_full {;	qui replace `var'=0 if `var'==.;};replace resid = . if date>=ym(1997,1);label variable resid "Original R&R shocks";label variable resid_romer "R&R shocks based on original R&R regression applied to full sample";label variable resid_full "Full-sample R&R shocks";saveold RR_monetary_shock_monthly.dta, replace;/* Generating time series of shocks: quarterly frequency */preserve;qui gen dateq = qofd(dofm(date));qui collapse (sum) resid resid_romer resid_full , by(dateq);replace resid = . if dateq>=yq(1997,1);rename dateq date;format date %tq;label variable resid "Original R&R shocks";label variable resid_romer "R&R shocks based on original R&R regression applied to full sample";label variable resid_full "Full-sample R&R shocks";saveold RR_monetary_shock_quarterly.dta, replace;restore;/* Generating time series of shocks: annual frequency */preserve;qui gen datey = year(dofm(date));qui collapse (sum) resid resid_romer resid_full, by(datey);replace resid = . if datey>=1997;rename datey date;format date %ty;label variable resid "Original R&R shocks";label variable resid_romer "R&R shocks based on original R&R regression applied to full sample";label variable resid_full "Full-sample R&R shocks";rename date year;saveold RR_monetary_shock_annual.dta, replace;restore;